//package com.inspur.edp.cef.generator.coreGenerator.base.serializer;
//
//import com.fasterxml.jackson.core.JsonGenerator;
//import com.fasterxml.jackson.databind.SerializerProvider;
//import com.inspur.edp.caf.generator.baseInfo.ParameterInfo;
//import com.inspur.edp.caf.generator.baseInfo.TypeInfo;
//import com.inspur.edp.caf.generator.method.ClassMethodGenerator;
//import com.inspur.edp.cef.designtime.api.IGspCommonField;
//import com.inspur.edp.cef.designtime.api.element.GspElementObjectType;
//import com.inspur.edp.cef.entity.changeset.IChangeDetail;
//import com.inspur.edp.cef.generator.coreGenerator.base.entityGenerator.CefDataTypeImplGeneratorContext;
//import com.inspur.edp.cef.generator.coreGenerator.entityGenerator.serializer.CMChangeJsonConvertorGenUtils;
//import com.inspur.edp.cef.generator.overall.CefGeneratorContext;
//import com.inspur.edp.cef.generator.overall.GenUtils;
//import com.inspur.edp.udt.designtime.api.entity.UnifiedDataTypeDef;
//import org.eclipse.jdt.core.dom.AST;
//import org.eclipse.jdt.core.dom.Block;
//import org.eclipse.jdt.core.dom.CastExpression;
//import org.eclipse.jdt.core.dom.ExpressionStatement;
//import org.eclipse.jdt.core.dom.MethodInvocation;
//import org.eclipse.jdt.core.dom.Modifier.ModifierKeyword;
//import org.eclipse.jdt.core.dom.ReturnStatement;
//import org.eclipse.jdt.core.dom.StringLiteral;
//import org.eclipse.jdt.core.dom.SwitchStatement;
//
//public class WriteModifyPropertyJsonGenerator extends ClassMethodGenerator {
//
//  protected CefDataTypeImplGeneratorContext nodeTypeGenContext;
//  public static final String methodName = "writeModifyPropertyJson";
//  public static final String paramWriter = "writer";
//  public static final String paramPropertyName = "propertyName";
//  public static final String paramValue = "value";
//  public static final String paramSerializer = "serializer";
//
//  public WriteModifyPropertyJsonGenerator(CefDataTypeImplGeneratorContext nodeTypeGenContext) {
//    this.nodeTypeGenContext = nodeTypeGenContext;
//  }
//
//  @Override
//  protected Block buildMethodBody() {
//    Block block = ast.newBlock();
//    SwitchStatement result = getSwitchBlock();
//    addCaseBlocks(result);
//    block.statements().add(result);
//    getDefaultStatement(block);
//    return block;
//  }
//
//  private void getDefaultStatement(Block result) {
//    ReturnStatement returnStatement = ast.newReturnStatement();
//    returnStatement.setExpression(ast.newBooleanLiteral(false));
//    result.statements().add(returnStatement);
//  }
//
//  private SwitchStatement getSwitchBlock() {
//    SwitchStatement switchStatement = ast.newSwitchStatement();
//    switchStatement.setExpression(ast.newSimpleName(paramPropertyName));
//    return switchStatement;
//  }
//
//  private void addCaseBlocks(SwitchStatement result) {
//    for (IGspCommonField item : nodeTypeGenContext.dataType.getContainElements()) {
//      addCaseBlock(item, result);
//    }
//  }
//
//  private void addCaseBlock(IGspCommonField element, SwitchStatement result) {
//    SerItemGenUtil.buildSwitchLables(ast, result, element.getLabelID());
//    result.statements().add(getWritePropStatement(ast,
//        element, nodeTypeGenContext.coreGenContext.getCefGenContext(), paramWriter,
//        paramPropertyName, paramValue, paramSerializer, this.nodeTypeGenContext));
//    ReturnStatement returnStatement = ast.newReturnStatement();
//    returnStatement.setExpression(ast.newBooleanLiteral(true));
//    result.statements().add(returnStatement);
//  }
//

//  // ORIGINAL LINE: internal static org.eclipse.jdt.core.dom.Statement GetWritePropStatement(IGspCommonField vmElement,
//  // CefGeneratorContext cefCtx, string paramWriter = paramWriter, string paramPropertyName =
//  // paramPropertyName, string paramValue = paramValue, string paramSerializer = paramSerializer)
//  private static org.eclipse.jdt.core.dom.Statement getWritePropStatement(
//      AST ast,
//      IGspCommonField vmElement,
//      CefGeneratorContext cefCtx,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer, CefDataTypeImplGeneratorContext dataTypeGenContext) {
//    if (vmElement.getIsUdt()) {
//      return getWriteUdtPropStatement(
//          ast, vmElement, cefCtx,
//          paramWriter, paramPropertyName, paramValue, paramSerializer, dataTypeGenContext);
//    }
//    if (vmElement.getObjectType() == GspElementObjectType.DynamicProp) {
//      return getWriteDynamicPropSetStatement(
//          ast, vmElement, paramWriter, paramPropertyName, paramValue, paramSerializer);
//    }
//    switch (vmElement.getObjectType()) {
//      case None:
//        return getWriteBasicPropStatement(
//            ast, vmElement, paramWriter, paramPropertyName, paramValue, paramSerializer,
//            dataTypeGenContext);
//      case Association:
//        return getWriteAssPropStatement(
//            ast, vmElement, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case Enum:
//        return getWriteEnumPropStatement(
//            ast, vmElement, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      default:
//        throw new RuntimeException();
//    }
//  }
//
//  // writeDynamicPropSetChange(JsonGenerator writer, SerializerProvider serializerProvider,
//  // IChangeDetail change, String propertyName, IDynamicPropSerItem serItem)
//  private static org.eclipse.jdt.core.dom.Statement getWriteDynamicPropSetStatement(
//      AST ast,
//      IGspCommonField element,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer) {
//    MethodInvocation methodInvocation = ast.newMethodInvocation();
//    methodInvocation.setName(
//        ast.newSimpleName(CMChangeJsonConvertorGenUtils.mName_WriteDynamicPropSetChange));
//    methodInvocation.arguments().add(ast.newSimpleName(paramWriter));
//    methodInvocation.arguments().add(ast.newSimpleName(paramSerializer));
//    methodInvocation.arguments()
//        .add(GenUtils.buildCastExpression(ast, IChangeDetail.class, ast.newSimpleName(paramValue)));
//    methodInvocation.arguments().add(ast.newSimpleName(paramPropertyName));
//    methodInvocation
//        .arguments()
//        .add(ast.newSimpleName(DynamicSerItemsFieldGenerator.getFieldName(element)));
//    return ast.newExpressionStatement(methodInvocation);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement
//  // getWriteBasicPropStatement(IGspCommonField vmElement, string paramWriter = paramWriter, string
//  // paramPropertyName = paramPropertyName, string paramValue = paramValue, string paramSerializer =
//  // paramSerializer)
//  private static ExpressionStatement getWriteBasicPropStatement(
//      AST ast,
//      IGspCommonField vmElement,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer, CefDataTypeImplGeneratorContext dataTypeGenContext) {
//    switch (vmElement.getMDataType()) {
//      case String:
//      case Text:
//        return getWriteStringPropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case Integer:
//        return getWriteIntPropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case Decimal:
//        return getWriteDecimalPropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case Date:
//        return getWriteDatePropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case DateTime:
//        return getWriteDateTimePropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer, dataTypeGenContext);
//      case Boolean:
//        return getWriteBoolPropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      case Binary:
//        return getWriteBinaryPropStatement(
//            ast, paramWriter, paramPropertyName, paramValue, paramSerializer);
//      default:
//        throw new RuntimeException();
//    }
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteStringPropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteStringPropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast,
//        CMChangeJsonConvertorGenUtils.mName_WriteString,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteIntPropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteIntPropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast, CMChangeJsonConvertorGenUtils.mName_WriteInt,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteDecimalPropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteDecimalPropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast,
//        CMChangeJsonConvertorGenUtils.mName_WriteDecimal,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteDatePropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteDatePropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast,
//        CMChangeJsonConvertorGenUtils.mName_WriteDate,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//
//  private static ExpressionStatement getWriteDateTimePropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer, CefDataTypeImplGeneratorContext dataTypeGenContext) {
//    if (SerItemGenUtil.getEnableStdDateTime(dataTypeGenContext)) {
//      return writeBasicStatement(
//          ast,
//          CMChangeJsonConvertorGenUtils.mName_WriteStdDateTime,
//          paramWriter,
//          paramPropertyName,
//          paramValue,
//          paramSerializer);
//    } else {
//      return writeBasicStatement(
//          ast,
//          CMChangeJsonConvertorGenUtils.mName_WriteDateTime,
//          paramWriter,
//          paramPropertyName,
//          paramValue,
//          paramSerializer);
//    }
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteBoolPropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteBoolPropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast, CMChangeJsonConvertorGenUtils.mName_WriteBool,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  getWriteBinaryPropStatement(string
//  // paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string paramValue =
//  // paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement getWriteBinaryPropStatement(
//      AST ast, String paramWriter, String paramPropertyName, String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast, CMChangeJsonConvertorGenUtils.mName_WriteBytes,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement
//  // getWriteAssPropStatement(IGspCommonField vmElement, string paramWriter = paramWriter, string
//  // paramPropertyName = paramPropertyName, string paramValue = paramValue, string paramSerializer =
//  // paramSerializer)
//  private static ExpressionStatement getWriteAssPropStatement(
//      AST ast,
//      IGspCommonField vmElement,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast, CMChangeJsonConvertorGenUtils.mName_WriteAssociation,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement
//  // getWriteEnumPropStatement(IGspCommonField vmElement, string paramWriter = paramWriter, string
//  // paramPropertyName = paramPropertyName, string paramValue = paramValue, string paramSerializer =
//  // paramSerializer)
//  private static ExpressionStatement getWriteEnumPropStatement(
//      AST ast,
//      IGspCommonField vmElement,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer) {
//    return writeBasicStatement(
//        ast, CMChangeJsonConvertorGenUtils.mName_WriteEnum,
//        paramWriter,
//        paramPropertyName,
//        paramValue,
//        paramSerializer);
//  }
//

//  // ORIGINAL LINE: private static org.eclipse.jdt.core.dom.Statement  getWriteUdtPropStatement(IGspCommonField
//  // vmElement, CefGeneratorContext cefCtx, string paramWriter = paramWriter, string
//  // paramPropertyName = paramPropertyName, string paramValue = paramValue, string paramSerializer =
//  // paramSerializer)
//  private static org.eclipse.jdt.core.dom.Statement getWriteUdtPropStatement(
//      AST ast,
//      IGspCommonField vmElement,
//      CefGeneratorContext cefCtx,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer, CefDataTypeImplGeneratorContext dataTypeGenContext) {
//    // protected void  writeNestedChange(JsonWriter writer, JsonSerializer serializer, string
//    // nestedConfigId, IChangeDetail value, string propertyName)

//    UnifiedDataTypeDef udtDef =
//        cefCtx.getMetadataContent(vmElement.getUdtPkgName(), vmElement.getUdtID());
//    MethodInvocation writeNestedInvocation = ast.newMethodInvocation();
//    writeNestedInvocation
//        .setName(ast.newSimpleName(CMChangeJsonConvertorGenUtils.mName_WriteNestedChange));
//    writeNestedInvocation.arguments().add(ast.newSimpleName(paramWriter));
//    writeNestedInvocation.arguments().add(ast.newSimpleName(paramSerializer));
//    StringLiteral udtConfigLiteral = ast.newStringLiteral();
//    udtConfigLiteral.setLiteralValue(udtDef.getUdtType());
//    writeNestedInvocation.arguments().add(udtConfigLiteral);
//
//    CastExpression castChangeDetailExpr = ast.newCastExpression();
//    castChangeDetailExpr.setType(ast.newSimpleType(ast.newName(IChangeDetail.class.getName())));
//    castChangeDetailExpr.setExpression(ast.newSimpleName(paramValue));
//    writeNestedInvocation.arguments().add(castChangeDetailExpr);
//
////    StringLiteral propNameLiteral = ast.newStringLiteral();
////    propNameLiteral.setLiteralValue(paramPropertyName);
//    writeNestedInvocation.arguments().add(ast.newSimpleName(paramPropertyName));
//
//    if (SerItemGenUtil.getEnableStdDateTime(dataTypeGenContext)) {
//      SerItemGenUtil.addGetNestedSerializeContextArg(ast, writeNestedInvocation);
//    }
//    return ast.newExpressionStatement(writeNestedInvocation);
//  }
//

//  // ORIGINAL LINE: private static ExpressionStatement  writeBasicStatement(string methodName,
//  // string paramWriter = paramWriter, string paramPropertyName = paramPropertyName, string
//  // paramValue = paramValue, string paramSerializer = paramSerializer)
//  private static ExpressionStatement writeBasicStatement(
//      AST ast,
//      String methodName,
//      String paramWriter,
//      String paramPropertyName,
//      String paramValue,
//      String paramSerializer) {
//    MethodInvocation writeInvocation = ast.newMethodInvocation();
//    writeInvocation.setName(ast.newSimpleName(methodName));
//    writeInvocation.arguments().add(ast.newSimpleName(paramWriter));
//    writeInvocation.arguments().add(ast.newSimpleName(paramValue));
//    writeInvocation.arguments().add(ast.newSimpleName(paramPropertyName));
//    writeInvocation.arguments().add(ast.newSimpleName(paramSerializer));
//    return ast.newExpressionStatement(writeInvocation);
//  }
//
//  @Override
//  protected boolean getIsOverride() {
//    return true;
//  }
//
//  @Override
//  protected java.util.ArrayList<ModifierKeyword> getAccessModifiers() {
//    return new java.util.ArrayList<ModifierKeyword>(
//        java.util.Arrays.asList(
//            new ModifierKeyword[]{
//                ModifierKeyword.PUBLIC_KEYWORD
//            }));
//  }
//
//  @Override
//  protected String getMethodName() {
//    return methodName;
//  }
//
//  @Override
//  protected java.util.ArrayList<ParameterInfo> getParameterCollection() {
//    ParameterInfo readerInfo = new ParameterInfo();
//    readerInfo.setParamName(paramWriter);
//    readerInfo.setParamType(new TypeInfo(JsonGenerator.class));
//
//    ParameterInfo propNameInfo = new ParameterInfo();
//    propNameInfo.setParamName(paramPropertyName);
//    propNameInfo.setParamType(new TypeInfo(String.class.getName()));
//
//    ParameterInfo valueInfo = new ParameterInfo();
//    valueInfo.setParamName(paramValue);
//    valueInfo.setParamType(new TypeInfo(Object.class.getName()));
//
//    ParameterInfo serializerInfo = new ParameterInfo();
//    serializerInfo.setParamName(paramSerializer);
//    serializerInfo.setParamType(new TypeInfo(SerializerProvider.class));
//
//    return new java.util.ArrayList<ParameterInfo>(
//        java.util.Arrays.asList(
//            new ParameterInfo[]{readerInfo, propNameInfo, valueInfo, serializerInfo}));
//  }
//
//  @Override
//  protected TypeInfo getReturnType() {
//    return new TypeInfo(boolean.class.getName());
//  }
//}
